/**
 * 热点问题
 * @author 黄广星 初步框架搭建
 * @author 程文智 风格统一和细节修正
 */
package com.taxsystem.huangguangxing.hotproblem;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;
import android.widget.SimpleAdapter;

import com.main.taxsystem.ListAndSearchActivity;
import com.main.taxsystem.R;

public class HotproblemMainActivity extends Activity {
	private List<Map<String,Object>> list = null;
	GridView gridView;
	HashMap<String, Object> map;
	SimpleAdapter saImageItems;

	private static final String TITLES[] = { 
		"营业税问题", 
		"企业所得税问题", 
		"个人所得税问题", 
		"其他税问题", 
		"房产交易问题",
		"社保费问题", 
		"资金问题", 
		"网报问题", 
		"网上开票问题", 
		"征管问题" };
	
	private static final int[] DRAWABLE_ID = new int[]{
		R.drawable.yyswt,
		R.drawable.qtszwt,//TODO:没有切片
		R.drawable.grsdswt,
		R.drawable.qtszwt,
		R.drawable.fcjywt,
		R.drawable.sbfwt,
		R.drawable.sbfwt,//TODO:没有切片
		R.drawable.wbwt,
		R.drawable.wskpwt,
		R.drawable.zgwt
	};

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.grid_view_layout_cwz);

		gridView = (GridView) findViewById(R.id.gridView);
		
		ActionBar bar = getActionBar();
        bar.setHomeButtonEnabled(true);
        bar.setIcon(R.drawable.actionbar_icon);
        bar.setDisplayHomeAsUpEnabled(true);
        bar.setBackgroundDrawable(new ColorDrawable(0xff34a4f7));

        list = new ArrayList<Map<String,Object>>();
		for(int i=0;i<TITLES.length;++i){
			Map<String,Object> map = new HashMap<String,Object>();
			map.put("title", TITLES[i]);
			map.put("icon", DRAWABLE_ID[i]);
			list.add(map);
		}
		saImageItems = new SimpleAdapter(this, list, R.layout.grid_item, 
				new String[]{"title","icon"},new int[]{R.id.text_item,R.id.image_item});
		gridView.setAdapter(saImageItems);
		gridView.setOnItemClickListener(new ItemClickListener());
		
	}

	class ItemClickListener implements OnItemClickListener {
		public void onItemClick(AdapterView<?> parent, View view, int position,
				long id) 
		{
			Intent intent = new Intent();
			intent.putExtra("title", TITLES[position]);
			intent.setClass(HotproblemMainActivity.this,
					ListAndSearchActivity.class);
			startActivity(intent);
		}
	}

}
